import { wechatrequest } from './API/request'
import { getStorageSync } from '../crossplatform/apiservice/storage'

/**
 * 反馈接口
 * */
export const addFeedBackRequest = ({ contact, content, name, picture, sourceType }) => {
  const userinfo = getStorageSync('userinfo')
  let role = userinfo && userinfo.role
  let companyId = userinfo && userinfo.companyId
  let userInfoB = userinfo && userinfo.userInfoB
  let userInfoC = userinfo && userinfo.userInfoC

  if (role == 'company' && companyId) {
    name = name || userInfoB.userName
    sourceType = sourceType || '招聘者'
  } else {
    sourceType = sourceType || '求职者'
    name = name || userInfoC.userName
  }

  return wechatrequest.post(`/feedback/addFeedBack`, {
    data: {
      contact,
      content,
      name,
      picture,
      sourceType
    }
  })
}
